﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Ex1.DefiningAttribute
{
    class VersionAttributeTest
    {
        static void Main(string[] args)
        {
            Type type = typeof(VersionsInAction);
            var methods = type.GetMethods();

            foreach (var method in methods)
            {
                object[] allAttributes = method.GetCustomAttributes(false);
                foreach (Attribute attribute in allAttributes)
                {
                    if (attribute is VersionAttribute)
                    {
                        VersionAttribute versionAttribute = (VersionAttribute)attribute;

                        Console.WriteLine("This class version is {0}. ", versionAttribute.Name);
                        Console.WriteLine("{0}", versionAttribute.Comment);
                    }
                }
            }
        }
    }
}
